<script setup>
    import {ref} from "vue";
    import adminApi from "@/api/admin.js";
    const adminList = ref([])
    //搜索条件
    const adminQuery = ref({
        name: '',
        email: ''
    })

    /*axios.get('http://localhost:8080/admin/list').then(response => {
        console.log(response)
        console.log(response.data) //result
        adminList.value = response.data.data
    }).catch(error => {
        console.log(error)
    })*/

    function search() {
        adminApi.list(adminQuery.value).then(result => {
            adminList.value = result.data
        })
        /*axios.get('http://localhost:8080/admin/list', {params: adminQuery.value}).then(response => {
            console.log(response)
            console.log(response.data) //result
            adminList.value = response.data.data
        }).catch(error => {
            console.log(error)
        })*/
    }

    search()
</script>

<template>
    名字：<input type="text" v-model="adminQuery.name">
    邮箱：<input type="text" v-model="adminQuery.email">
    <el-button type="primary" @click="search">搜索</el-button>
    <el-table :data="adminList" stripe border  style="width: 100%">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="ID" />
        <el-table-column prop="name" label="名字"  />
        <el-table-column prop="password" label="密码"  />
        <el-table-column prop="email" label="邮箱"  />
        <el-table-column prop="phone" label="电话"  />
    </el-table>
<!--    <table border="1" cellspacing="0">
        <tr>
            <td>ID</td>
            <td>名字</td>
            <td>密码</td>
            <td>邮箱</td>
            <td>电话</td>
        </tr>
        <tr v-for="admin of adminList" :key="admin.id">
            <td>{{admin.id}}</td>
            <td>{{admin.name}}</td>
            <td>{{admin.password}}</td>
            <td>{{admin.email}}</td>
            <td>{{admin.phone}}</td>
        </tr>
    </table>-->

</template>

<style scoped>

</style>